<template>
  <div class="card-box" @click="handleToDetail(id)">
    <van-image :src="image" class="img" fit="cover">
      <template v-slot:loading>
        <van-loading type="spinner" size="20" />
      </template>
    </van-image>
    <div class="name van-ellipsis">{{name}}</div>
    <div class="writer van-ellipsis">{{writer}}</div>
  </div>
</template>

<script>
import Taro from "@tarojs/taro";
export default {
  name: "Card",
  props: {
    name: String,
    writer: String,
    id: Number,
    image:{
      default:'http://foglake.sanye666.top/images/default-covor.jpg',
      type:String
    }
  },
  data() {
    return {};
  },
  methods: {
    handleToDetail(id) {
      Taro.navigateTo({
        url: `/pages/bookdetail/bookdetail?id=${id}`,
      });
    },
  },
};
</script>

<style scoped>
.card-box {
  width: 150px;
  margin-bottom: 40px;
}

.img {
  height: 200px;
  width: 150px;
  border-radius: 12px;
  background-repeat: no-repeat;
  background-size: 200px 150px;
}

.name {
  font-size: 24px;
  font-family: Alibaba PuHuiTi;
  font-weight: 600;
  color: rgba(6, 27, 65, 0.75);
  line-height: 24px;
  margin-bottom: 10px;
  margin-left: 3px;
}

.writer {
  font-size: 20px;
  font-family: Alibaba PuHuiTi;
  font-weight: 400;
  color: rgba(6, 27, 65, 0.35);
  margin-left: 3px;
}
</style>